#include <DrawingMesh.hpp>

Drawing::Mesh::~Mesh()
{}

Drawing::Mesh::Mesh(std::string name) : Modeling::Mesh(name)
{}

Drawing::Polygon* Drawing::Mesh::addPolygon(Vector3f* V1, Vector3f* V2, Vector3f* V3)
{
	Drawing::Polygon* polygon = new Drawing::Polygon(V1, V2, V3);
	this->polygon.push_back(polygon);
	return polygon;
}

Drawing::Polygon* Drawing::Mesh::getPolygon(unsigned int index)
{
    return (Drawing::Polygon*)this->polygon[index];
}

void Drawing::Mesh::animate(unsigned int frame)
{
	glPushMatrix();
	glMultMatrixf((float*)this->getMatrix(frame));

	for (unsigned int i=0 ; i<this->getPolygonsQty() ; i++)
		this->getPolygon(i)->animate();

	for (unsigned int i=0 ; i<this->getChildrenQty() ; i++)
		this->getChild(i)->animate(frame);

	glPopMatrix();
}
